In a multiprocessor system, each CPU (Central Processing Unit) individually maintains a queue, thus the loads of multiple CPUs are unbalanced, and processes (or threads) are required to be migrated from the CPU with a large load into the CPU with a small load to balance the loads, wherein the CPU from which the processes are migrated is referred to as the local CPU, and the CPU into which the processes are migrated is referred to as the target CPU.
In the prior art, a method for balancing load by migrating processes based on the condition of being cold or hot of the processes in the cache is provided, specifically including: firstly, setting a threshold (the maximum value) for the waiting time of processes, the waiting time of a process refers to the time interval from a moment at which whether or not to migrate the process is judged to a moment at which the latest execution of the process is ended; next, judging whether the waiting time of a process in the local CPU is larger than the threshold; if yes, deeming that the process is cold in the cache, and migrating the process into the target CPU; if no, deeming that the process is hot in the cache and not migrating the process. On each CPU, the above method is circularly utilized to migrate processes, until a certain load balance is achieved among the CPUs.
Although the effect of balancing loads can be achieved by utilizing the above method, some processes occupying a large memory space may be migrated into the target CPU. Thus, when being executed on the target CPU, these processes need to access the remote node memory for a number of times, or need to copy a large amount of data relevant to the processes from the remote node memory to the local node memory, thereby influencing the performance of the system.